package com.ssyt.wxstore.sys.entity;

import java.util.List;

import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.OneToMany;
import javax.persistence.Table;

import org.hibernate.annotations.DynamicUpdate;
import org.hibernate.annotations.GenericGenerator;

@Entity
@Table(name = "sys_user")
@DynamicUpdate
public class SysUser {
	@Id
	@GenericGenerator(name = "generator", strategy = "uuid")
	@GeneratedValue(generator = "generator")
	private String id;
	private String code;
	private String password;
	private String name;
	private Integer state;
	@OneToMany(cascade = CascadeType.ALL)
	@JoinTable(name = "sys_user_role", joinColumns = { @JoinColumn(name = "sys_user_id") }, inverseJoinColumns = { @JoinColumn(name = "sys_role_id") })
	private List<SysRole> sysRoleList;
	@OneToMany(cascade = CascadeType.ALL)
	@JoinColumn(name = "sys_user_id")
	private List<SysUserRole> sysUserRoleList;

	public List<SysRole> getSysRoleList() {
		return sysRoleList;
	}

	public void setSysRoleList(List<SysRole> sysRoleList) {
		this.sysRoleList = sysRoleList;
	}

	public String getId() {
		return id;
	}

	public void setId(String id) {
		this.id = id;
	}

	public String getCode() {
		return code;
	}

	public void setCode(String code) {
		this.code = code;
	}

	public String getPassword() {
		return password;
	}

	public void setPassword(String password) {
		this.password = password;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getState() {
		if (state == 1) {
			return "已启用";
		} else if (state == 2) {
			return "已禁用";
		} else {
			return "unkown";
		}

	}

	public void setState(Integer state) {
		this.state = state;
	}

	public List<SysUserRole> getSysUserRoleList() {
		return sysUserRoleList;
	}

	public void setSysUserRoleList(List<SysUserRole> sysUserRoleList) {
		this.sysUserRoleList = sysUserRoleList;
	}

	public SysUser() {
		super();
	}

}
